let Home = {
    baseUrl: 'http://81.71.65.4:3003',
    uname: localStorage.getItem('uname'),
    login() {
        let logout = document.querySelector('.logout')
        if (this.uname == null) {
            logout.style.display = 'none'
            document.querySelector('.head a').innerText = '登录'
            console.log('你还没有登录呢');
            return
        } else if (this.uname != null) {
            logout.style.display = 'flex'
            document.querySelector('.head a').innerText = this.uname
            document.querySelector('.head a').href = '#'
                // console.log(Home.uname);
        }
    },
}

onload = () => {
    Home.login()
    let logout = document.querySelector('.logout')
    logout.addEventListener('click', () => {
        axios.get(Home.baseUrl + '/user/logout').then((res) => {
            localStorage.clear('token')
            localStorage.clear('uname')
            Home.login()
            location.reload()
        })

    })

}